const http = require('http');
const fs = require('fs');

const server = http.createServer((req, res) => {
    const fileName = `./www${req.url}` ;
    console.log(fileName);
    fs.readFile(fileName, (err, data) => {
        if (err) {
            res.write('404 找不到页面!');
        } else {    
            res.write(data);
        }
        res.end();
    });
});

server.listen(8001, () => {
    console.log('服务启动成功!');
})